{include file="public/header" /}
<!--main content start-->
<section class="main-content-wrapper">
    <section id="main-content">
        <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">代理添加</h3>
                    <!--<div class="actions pull-right">-->
                        <!--<i class="fa fa-chevron-down"></i>-->
                        <!--<i class="fa fa-times"></i>-->
                    <!--</div>-->
                </div>
                <div class="panel-body">
                <form action="/admin/agent/agent_save" method="post" enctype="multipart/form-data" class="form-horizontal form-border">
                    <input name="id" value="{$id|default=''}" type="hidden">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">代理姓名：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="name" autocomplete="off" value="{$name|default=''}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">代理级别：</label>
                        <div class="col-sm-2">
                            <select class="form-control input-sm" name="level_id">
                                {volist name="agent_levels" id="vo"}
                                <option value="{$vo.id}" <?php if(isset($level_id)){if($level_id==$vo['id'])echo 'selected';}?>>{$vo.title}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">手机号：</label>
                        <div class="col-sm-2">
                            <input type="text" class="form-control" name="phone" value="{$phone|default=''}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">微信：</label>
                        <div class="col-sm-2">
                            <input type="text" class="form-control" name="weixin" value="{$weixin|default=''}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">搜索数量：</label>
                        <div class="col-sm-2">
                            <input type="text" class="form-control" name="view" value="{$view|default='1'}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">代理时间：</label>
                        <div class="col-sm-8">
                            <div class="col-md-5 grid_box1 input-append date form_datetime4" style="padding-left: 0;">
                                <input type="text" class="form-control" name="s_time" value="<?php if(!empty($s_time)) echo (date('Y-m-d H:i',$s_time));else echo (date('Y-m-d H:i',time()));  ?>" style="width: 70%;float: left;">
                                <div>
                                    <span class="add-on"><i class="icon-remove"></i></span>
                                    <span class="add-on"><i class="icon-th"></i></span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">到期时间：</label>
                        <div class="col-sm-8">
                            <div class="col-md-5 grid_box1 input-append date form_datetime4" style="padding-left: 0;">
                                <input type="text" class="form-control" name="e_time" value="<?php if(!empty($e_time)) echo (date('Y-m-d H:i',$e_time));else echo (date('Y-m-d H:i',strtotime('+1year')));  ?>" style="width: 70%;float: left;">
                                <div>
                                    <span class="add-on"><i class="icon-remove"></i></span>
                                    <span class="add-on"><i class="icon-th"></i></span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">备注：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" placeholder="代理备注" name="remarks" value="{$remarks|default=''}">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">状态：</label>
                        <div class="col-sm-2">
                            <input name="status" value="1" type="radio" {if isset($status)}{if condition="($status == 1)"} checked="checked"  {else /}{/if}{else /}checked="checked" {/if}}>正常&nbsp;&nbsp;
                            <input name="status" type="radio" value="2" {if isset($status)}{if condition="($status == 2)"} checked="checked"  {else /}{/if}{else /}{/if}}>冻结
                        </div>
                    </div>
                    <div class="panel-body">
                        <button type="submit" class="btn btn_5 btn-lg btn-default w_update">发布</button>
                    </div>
                </form>
                </div>
            </div>
        </div>
        </div>
    </section>
</section>
<style>
    @media (min-width: 768px){
        .form-horizontal .control-label {
             text-align: left;
        }
    }
    /*时间插件*/
    .add-on{display:inline-block;width:auto;height:36px;min-width:16px;padding:4px 5px;font-size:14px;font-weight:normal;line-height:32px;text-align:center;text-shadow:0 1px 0 #fff;background-color:#eee;border:1px solid #ccc}
    .input-prepend .add-on:first-child{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}
    .input-append .add-on{margin-left: -4px;}
    .input-append .add-on:last-child{margin-left:-4px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}
    [class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;margin-top:1px;*margin-right:.3em;line-height:14px;vertical-align:text-top;background-image:url("http://cdn.bootcss.com/twitter-bootstrap/2.2.2/img/glyphicons-halflings.png");background-position:14px 14px;background-repeat:no-repeat}
    .icon-th{background-position:-240px 0}
    .icon-remove{background-position:-312px 0}
    @media screen and (max-width: 850px) {
        .add-on {
            display: table-cell
        }
    }
    #seo_title{
        position: absolute;
        z-index: 9;
        width: 89%;
        margin: 0;
        padding: 6px 0;
        background-color: #fff;
        border: 1px solid #ccc;
        border-radius: 4px;
        top: 35px;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        -webkit-text-overflow: ellipsis;
        display: none;
    }
    #seo_title li{
        height: 30px;
        line-height: 30px;
        cursor: pointer;
        border-bottom: 1px solid #ccc;
        padding: 0 12px;
    }
    #seo_title li:hover{
        background-color: #c6c7c7;
        color: #fff;
    }
</style>
<!--回车添加tag-->
<style>
    .tags {
        background-color: #fff;
        border: 1px solid #d5d5d5;
        color: #777;
        display: inline-block;
        padding: 4px 6px;
        vertical-align: middle;
    }
    .tags:hover {
        border-color: #f59942;
        outline: 0 none;
    }
    .tags[class*="span"] {
        float: none;
        margin-left: 0;
    }
    .tags input[type="text"], .tags input[type="text"]:focus {
        border: 0 none;
        box-shadow: none;
        display: inline;
        line-height: 14px;
        margin: 0;
        outline: 0 none;
        padding: 0;
        width: 100%;
    }
    .tags .tag {
        background-color: #91b8d0;
        color: #fff;
        display: inline-block;
        font-size: 12px;
        font-weight: normal;
        margin-bottom: 3px;
        margin-right: 3px;
        padding: 4px 22px 5px 9px;
        position: relative;
        text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15);
        transition: all 0.2s ease 0s;
        vertical-align: baseline;
        white-space: nowrap;
    }
    .tags .tag .close {
        bottom: 0;
        color: #fff;
        float: none;
        font-size: 12px;
        line-height: 20px;
        opacity: 1;
        position: absolute;
        right: 0;
        text-align: center;
        text-shadow: none;
        top: 0;
        width: 18px;
    }
    .tags .tag .close:hover {
        background-color: rgba(0, 0, 0, 0.2);
    }
    .close {
        color: #000;
        float: right;
        font-size: 21px;
        font-weight: bold;
        line-height: 1;
        opacity: 0.2;
        text-shadow: 0 1px 0 #fff;
    }
    .close:hover, .close:focus {
        color: #000;
        cursor: pointer;
        opacity: 0.5;
        text-decoration: none;
    }
    button.close {
        background: transparent none repeat scroll 0 0;
        border: 0 none;
        cursor: pointer;
        padding: 0;
    }
    .tags .tag-warning {
        background-color: #ffb752;
    }
</style>

<script>
    $(function() {
        $(".tags_enter").blur(function() { //焦点失去触发
            addTag($(this));
            $(this).parents(".tags").css({"border-color": "#d5d5d5"})
        }).keydown(function(event) {
            var key_code = event.keyCode;
            if (key_code == 13) { //enter
                addTag($(this));
            }
        });
        $(".close").live("click", function() {
            $(this).parent(".tag").remove();
        });
        $(".tags").click(function() {
            $(this).css({"border-color": "#f59942"})
        }).blur(function() {
            $(this).css({"border-color": "#d5d5d5"})
        })
    })
    function addTag(obj) {
        var tag = obj.val();
        if (tag != '') {
            var i = 0;
            $(".tag").each(function() {
                if ($(this).text() == tag + "×") {
                    $(this).addClass("tag-warning");
                    setTimeout("removeWarning()", 400);
                    i++;
                }
            })
            obj.val('');
            if (i > 0) { //说明有重复
                return false;
            }
            $("#form-field-tags").before("<span class='tag'>" + tag + " <input name='tags[]' type='hidden' value="+tag+"><button class='close' type='button'>×</button></span>"); //添加标签
            addtag(tag);
        }
    }
    function removeWarning() {
        $(".tag-warning").removeClass("tag-warning");
    }
    function addtag(name){
        $.ajax({
            type:'post',
            dataType:'json',
            data:'name='+name,
            url:"/admin/tags/tags_add",
            success:function(data){
                if(data.status == 0){
                    return;
                }else{
                    alert(data.msg);
                }
            }
        });
    }
    var type=$("#column option:selected").val();
    get_column(type);
    $("#column").bind('change',function(){
        var type=$("#column option:selected").val();
        get_column(type);
    })
    function get_column(id){
        $.ajax({
            type:'get',
            dataType:'json',
            data:'c_id='+id,
            url:"/admin/column/search_index",
            success:function(data){
                if(data.status == 0){
                    var html = '';
                    var data = data.data;
                    for (var i=0;i<data.length;i++)
                    {
                        if({$s_column|default=0}==data[i].id){
                            html += ' <option value="'+data[i].id+'" selected>'+data[i].name+'</option>';
                        }else{
                            html += ' <option value="'+data[i].id+'">'+data[i].name+'</option>';
                        }
                    }
                    $('#z_cid').html(html);

                }else{

                }
            }
        });
    }
</script>
<!--百度编辑器插件-->
<script type="text/javascript" charset="utf-8" src="/web_admin/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/web_admin/ueditor/ueditor.all.min.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="/web_admin/ueditor/lang/zh-cn/zh-cn.js"></script>

<!--时间插件-->
<script src="/web_admin/js/bootstrap-datetimepicker.min.js"></script>
<link href="/web_admin/css/datetimepicker.css" rel='stylesheet' type='text/css' />

<script>
    $(".form_datetime4").datetimepicker({
        format: "yyyy-mm-dd hh:ii",
        autoclose: true,
        todayBtn: true
    });
</script>
<script>
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');
</script>
<script>
    /**
     * 从 file 域获取 本地图片 url
     */
    function getFileUrl(sourceId) {
        var url;
        if (navigator.userAgent.indexOf("MSIE")>=1) { // IE
            url = document.getElementById(sourceId).value;
        } else if(navigator.userAgent.indexOf("Firefox")>0) { // Firefox
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        } else if(navigator.userAgent.indexOf("Chrome")>0) { // Chrome
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        }
        return url;
    }
    /**
     * 将本地图片 显示到浏览器上
     */
    function preImg(sourceId, targetId) {
        var url = getFileUrl(sourceId);
        var imgPre = document.getElementById(targetId);
        imgPre.src = url;
    }
</script>
<script>
    var input=document.querySelector("#title");// 获取文档中 id="title" 的元素：
    var ul=document.querySelector("#seo_title");

    input.onkeyup=function(){
        var script=document.createElement("script");
        script.src='https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd='+this.value+'&cb=fn1';

        document.body.appendChild(script);
        document.body.removeChild(script);
    }

    function fn1(data){
        var str='';
        if(!data.s.length){
            ul.style.display='none';
            ul.innerHTML='';
        }else{
            ul.style.display='block';

            for(var i=0;i<data.s.length;i++){
                str+='<li>'+data.s[i]+'</li>';
            }
            ul.innerHTML=str;
            $(".seo_title").show(500);
        }
    };
    $(document).on('click','#seo_title li',function(){
        $('#title').val($(this).text());
        $('#seo_title').hide();
    });
    $(document).on('click','.wyc',function(){
        var arr = [];
//        arr.push(UE.getEditor('editor').getContent());
        arr.push(UE.getEditor('editor').getPlainTxt());

        $.ajax({
            type:'post',
            dataType:'json',
            data:'con='+arr,
            url:"http://wyc.chinaluohong.cn/api.php",
            success:function(data){
                if(data.status == 0){

                    //修改内容
                    UE.getEditor('editor').setContent(data.data, 0);
                }else{
                    alert(data.msg);
                }
            }
        });
    });

</script>
<!--main content end-->
{include file="public/footer" /}